package com.myidis.controller;

import com.myidis.entity.CIResult;
import com.myidis.entity.FullCIResult;
import com.myidis.entity.IndexResultList;
import com.myidis.request.DICalculatorReq;
import com.myidis.servlet.CICalculateServlet;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.ArrayList;

@Controller
@RequestMapping("/CICalculate")
public class CICalculateController {
    @Autowired
    private CICalculateServlet cICalculateServlet;

    //计算结果列表调用的接口
    @ResponseBody
    @RequestMapping("/list")
    public ArrayList<IndexResultList> list() {
        return cICalculateServlet.all();
    }

    //查看某一条具体计算结果的接口
    @ResponseBody
    @RequestMapping("/Data")
    public ArrayList<FullCIResult> data(@RequestBody IndexResultList sea) {
        return cICalculateServlet.getData(sea);
    }

    //查看某一条计算结果的信息的接口
    @ResponseBody
    @RequestMapping("/info")
    public FullCIResult info(@RequestBody int sea) {
        return cICalculateServlet.getInfo(sea);
    }


    //计算一条新结果的接口
    @ResponseBody
    @RequestMapping("/calculate")
    public ArrayList<CIResult> calculate(@RequestBody DICalculatorReq req) {
        return cICalculateServlet.calculate(req);
    }

    //删除某一结果的接口
    @ResponseBody
    @RequestMapping("/del")
    public int calculate(@RequestBody int del) {
        return cICalculateServlet.delect(del);
    }

}
